package com.bdyc.service.springImpl;

import org.springframework.stereotype.Service;

import com.bdyc.service.spring.FastDrawInfoService;
@Service("fastDrawInfoService")
public class FastDrawInfoServiceImpl implements FastDrawInfoService {

//	@Autowired(required=true)
//	@Qualifier("fastDrawInfoMapper")
//	private FastDrawInfoMapper fastDrawInfoMapper;
	
//	//操作快画mapper
//	@Autowired(required=true)
//	@Qualifier("orderInfoMapper")
//	private OrderInfoMapper orderInfoMapper;
//	@Autowired(required=true)
//	@Qualifier("orderDrawRelMapper")
//	private OrderDrawRelMapper orderDrawRelMapper;
//	@Autowired(required=true)
//	@Qualifier("userOrderRelMapper")
//	private UserOrderRelMapper userOrderRelMapper;
//	//操作类别mapper
//	@Autowired(required=true)
//	@Qualifier("cateKeyRelMapper")
//	private CateKeyRelMapper cateKeyRelMapper;
//	@Autowired(required=true)
//	@Qualifier("drawCateRelMapper")
//	private DrawCateRelMapper drawCateRelMapper;
	
	//添加方法6张表
//	public void addFastDrawInfo(FastDrawInfo fastDrawInfo, Integer id) {
//		OrderInfo orderInfo = new OrderInfo();
//		UserOrderRel userOrderRel = new UserOrderRel();
//		OrderDrawRel orderDrawRel = new OrderDrawRel();
//		//1插入快写表
//		fastDrawInfoMapper.insert(fastDrawInfo);
//		//封装orderInfo
//		orderInfo.setCreateTime(MyDateFormat.getTime());//添加创建时间
//		orderInfo.setName(fastDrawInfo.getName());//设置任务名称
//		orderInfo.setFlag(AppConstant.TASKDRAW);//设置任务种类
//		orderInfo.setNum(BusinessNumber.getOrderNo());//设置任务号
//		orderInfo.setPrice(fastDrawInfo.getPrice());//设置价格
//		orderInfo.setStatus(AppConstant.TASKFLAGONE);//设置任务状态
//		//2插入任务表
//		orderInfoMapper.insert(orderInfo);
//		//3插入userOrderRel表
//		userOrderRel.setOid(orderInfo.getId());
//		userOrderRel.setUid(id);
//		userOrderRelMapper.insert(userOrderRel);
//		//4插入orderDrawRel表
//		orderDrawRel.setOid(orderInfo.getId());
//		orderDrawRel.setDid(fastDrawInfo.getId());
//		orderDrawRelMapper.insert(orderDrawRel);
//		//5.6插入DrawCateRel表和cateKeyRel表
//		String degree = fastDrawInfo.getDegree();
//		String [] degreeArr = degree.split(",");
//		for(int i=0;i<degreeArr.length;i++){
//			DrawCateRel DrawCateRel = new DrawCateRel();
//			DrawCateRel.setDid(fastDrawInfo.getId());
//			DrawCateRel.setCid(Integer.valueOf(degreeArr[i]));
//			drawCateRelMapper.insert(DrawCateRel);
//			/**如果数据库初始化后 插入DrawCateRel表和cateKeyRel表将无法匹配*/
//			if(degreeArr[i].equals("5")){
//				CateKeyRel cateKeyRel = new CateKeyRel();
//				cateKeyRel.setCid(5);
//				cateKeyRel.setDid(fastDrawInfo.getId());
//				cateKeyRel.setKid(Integer.valueOf(fastDrawInfo.getKeyword()));
//				cateKeyRelMapper.insert(cateKeyRel);
//			}
//		}
//	}
//	//修改快画方法 修改
//	public void updateFastDrawInfo(FastDrawInfo fastDrawInfo) {
//		//1删除DrawCateRel表 根据did
//		drawCateRelMapper.deleteByDId(fastDrawInfo.getId());
//		//2删除cateKeyRel表 根据did
//		cateKeyRelMapper.deleteByDId(fastDrawInfo.getId());
//		//从新插入
//		String degree = fastDrawInfo.getDegree();
//		String [] degreeArr = degree.split(",");
//		for(int i=0;i<degreeArr.length;i++){
//			DrawCateRel DrawCateRel = new DrawCateRel();
//			DrawCateRel.setDid(fastDrawInfo.getId());
//			DrawCateRel.setCid(Integer.valueOf(degreeArr[i]));
//			drawCateRelMapper.insert(DrawCateRel);
//			/**如果数据库初始化后 插入DrawCateRel表和cateKeyRel表将无法匹配*/
//			if(degreeArr[i].equals("5")){
//				CateKeyRel cateKeyRel = new CateKeyRel();
//				cateKeyRel.setCid(5);
//				cateKeyRel.setDid(fastDrawInfo.getId());
//				cateKeyRel.setKid(Integer.valueOf(fastDrawInfo.getKeyword()));
//				cateKeyRelMapper.insert(cateKeyRel);
//			}
//		}
//		OrderInfo updateOrderInfo = orderInfoMapper.selectOrderByDid(fastDrawInfo.getId());
//		//任务编号已经固定 不能更改
//		updateOrderInfo.setCreateTime(MyDateFormat.getTime());//添加创建时间
//		updateOrderInfo.setName(fastDrawInfo.getName());//设置任务名称
//		updateOrderInfo.setFlag(AppConstant.TASKDRAW);//设置任务种类
//		updateOrderInfo.setPrice(fastDrawInfo.getPrice());//设置价格
//		updateOrderInfo.setStatus(AppConstant.TASKFLAGONE);//设置任务状态
//		fastDrawInfoMapper.updateByPrimaryKeySelective(fastDrawInfo);
//		orderInfoMapper.updateByPrimaryKey(updateOrderInfo);
//	}
//
//	public void delFastDrawInfo(Integer id) {
//		//1删除order表 
//		orderInfoMapper.deleteById(id);
//		//2删除fastDraw表 根据oid查询wid
//		Integer did = orderInfoMapper.selectDidByOId(id);
//		fastDrawInfoMapper.deleteByPrimaryKey(did);
//		//3删除orderDrawRel表 根据did
//		orderDrawRelMapper.deleteByDId(did);
//		//4删除userOrderRel表 根据oId
//		userOrderRelMapper.deleteByOId(id);
//		//5删除DrawCateRel表 根据did
//		drawCateRelMapper.deleteByDId(did);
//		//6删除cateKeyRel表 根据did
//		cateKeyRelMapper.deleteByDId(did);
//	}
//
//	public FastDrawInfo findFastDrawInfoByOId(Integer oid) {
//		return fastDrawInfoMapper.findFastDrawInfoByOId(oid);
//	}

}
